import Login from "./components/login";

// 动态路由
// export function patchRoutes({ routes }) {
//     routes.unshift({
//         path: '/login',
//         exact: true,
//         component: Login
//         // component: require('./components/login').default
//     })
// }

let extraRoutes;
export function modifyClientRenderOpts(opts) {
    // 渲染前，进行路由合并
    opts.routes.unshift(...extraRoutes);
    return opts;
}
export function render(oldRender) {
    fetch('/api/routes').then(res => res.json())
    .then(res => {
        extraRoutes = res.map(item => {
            let component = item.component;
            component = require(`./components/${component}`).default;
            return { ...item, component };
        });
        oldRender();
    })
}